package sajat.onlab;

import java.util.ArrayList;
import java.util.ListIterator;

public class RouteSingleton {
	
	private static RouteSingleton instance = null;
	private ArrayList<RouteStep> steps;
	private ListIterator<RouteStep> stepsit;
	private RouteStep highlighted;
	
	   protected RouteSingleton() {
	      steps=new ArrayList<RouteStep>();
	   }
	   
	   public static RouteSingleton getInstance() {
	      if(instance == null) {
	         instance = new RouteSingleton();
	      }
	      return instance;
	   }
	   
	   public void add(RouteStep step) {
		   steps.add(step);
	   }
	   
	   public void deleteSteps() {
		   if (!steps.isEmpty())
		   steps.clear();
	   }
	   
	   public ArrayList<RouteStep> getSteps() {
		   return steps;
	   }
	   
	   public RouteStep getHighlighted() {
		   return highlighted;
	   }
	   
	   public void highlightFirst() {
		   if (steps.size()!=0) {
		   stepsit=steps.listIterator(0);
		   highlighted = stepsit.next();
		   }
	   }
	   
	   public boolean highlightNext() {
		   if (stepsit.hasNext()) {
			   highlighted = stepsit.next();
			   return true;
		   }
		   else {
			   return false;
		   }
	   }
}
